from io import BufferedReader, BytesIO
import numpy as np  #矩阵算法库
import cv2  #openCV库

img = open(r"D:\picture\replace\5.png", "rb") # 假设postman传了图片到服务端，服务端接收到后为img

# 转成BufferedReader格式
img_buff = BufferedReader(img)

# 得到byte数据
img_byte = BufferedReader.read(img_buff )

# 转成numpy数组
nparr = np.frombuffer(img_byte , dtype=np.uint8)


# 转成cv2.imread相同效果的数据
# img_decode = cv2.imdecode(nparr, 1)
# print(img_decode.shape)
arr = np.array(nparr)
print(arr)
file_like = BytesIO(arr)
print(file_like.read())